const { Model, DataTypes } = require('sequelize');

const sequelize = require('./database');
const Match = require('./match');

class MatchGroup extends Model {}

MatchGroup.init({
  groupname: {
    type: DataTypes.STRING,
    allowNull: false,
    unique: false
  },
  minBirthDay: {
    type: DataTypes.DATE,
    allowNull: false,
    unique: false
  },
  maxBirthDay: {
    type: DataTypes.DATE,
    allowNull: false,
    unique: false
  },
  matchId: {
    type: DataTypes.INTEGER,
    allowNull: false,
    references: {
      model: Match, // 指定关联的模型
      key: 'id'
    }
  }
}, {
  sequelize,
  modelName: 'matchgroup'
});
MatchGroup.belongsTo(Match,{ foreignKey: 'matchId' })



module.exports = MatchGroup;